/**
 * Created by saman on 12/30/14.
 */
var domain = getDomain();

function editProfileUsername( userID, newUsername ){

    var json = { "userID" : userID, "username" : newUsername };

    $.ajax({

        url: domain+"/changeUsernameController.ajax",
        type: "POST",
        data: JSON.stringify(json),
        cache: false,
        beforeSend: function(xhr){
            xhr.setRequestHeader( "Accept", "application/json" );
            xhr.setRequestHeader( "Content-Type", "application/json" );
        },
        success: function(response){
            alert( "Profile username changed successfully!" );
        },
        error: function (jqXhr, textStatus, errorThrown) {
            alert(textStatus);
        }
    });

}
/*
function editProfilePasswrod( userID, newPassword ){

    var json = { "id" : userID, "password" : newPassword };

    $.ajax({

        url: "http://localhost:8080/changeUserPassword.ajax",
        type: "POST",
        data: JSON.stringify(json),
        cache: false,
        beforeSend: function(xhr){
            xhr.setRequestHeader( "Accept", "application/json" );
            xhr.setRequestHeader( "Content-Type", "application/json" );
        },
        success: function(response){
            alert( "Profile password changed successfully!" );
        },
        error: function (jqXhr, textStatus, errorThrown) {
            alert(textStatus);
        }
    });

}
*/

function editProfileFirstName( userID, firstName ){

    var json = { "userID" : userID, "firstName" : firstName };

    alert( userID + " " + firstName );

    $.ajax({

        url: domain+"/changeUserFirstName.ajax",
        type: "POST",
        data: JSON.stringify(json),
        cache: false,
        beforeSend: function(xhr){
            xhr.setRequestHeader( "Accept", "application/json" );
            xhr.setRequestHeader( "Content-Type", "application/json" );
        },
        success: function(response){
            alert( "Profile first name changed successfully!" );
        },
        error: function (jqXhr, textStatus, errorThrown) {
            alert(textStatus);
        }

    });

}

function editProfileLastName( userID, lastName ){

    var json = { "userID" : userID, "lastName" : lastName };

    $.ajax({

        url: domain+"/changeUserLastName.ajax",
        type: "POST",
        data: JSON.stringify(json),
        cache: false,
        beforeSend: function(xhr){
            xhr.setRequestHeader( "Accept", "application/json" );
            xhr.setRequestHeader( "Content-Type", "application/json" );
        },
        success: function(response){
            alert( "Profile last name changed successfully!" );
        },
        error: function (jqXhr, textStatus, errorThrown) {
            alert(textStatus);
        }

    });

}

function editProfileBirthday( userID, birthDate ){

    var json = { "id" : userID, "birthDate" : birthDate };

    $.ajax({

        url: domain+"/changeUserBirthDateController.ajax",
        type: "POST",
        data: JSON.stringify(json),
        cache: false,
        beforeSend: function(xhr){
            xhr.setRequestHeader( "Accept", "application/json" );
            xhr.setRequestHeader( "Content-Type", "application/json" );
        },
        success: function(response){
            alert( "Profile last name changed successfully!" );
        },
        error: function (jqXhr, textStatus, errorThrown) {
            alert(textStatus);
        }

    });

}